/**
 * Creat by TanLei
 * Description:
 * User:86183
 * Date:2022-05-12
 * Time:10:50
 */
public class Demo19 {
    private static Object locker = new Object();

    public static void main(String[] args) throws InterruptedException {
        Thread waiter = new Thread(() -> {
            while (true) {
                synchronized (locker) {
                    System.out.println("wait 之前");
                    try {
                        locker.wait();
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                    System.out.println("wait 结束");
                }
            }
        });
        waiter.start();

        Thread.sleep(3000);

        Thread notifier = new Thread(() -> {

                synchronized (locker) {
                    System.out.println("notify 之前");
                    locker.notify();
                    System.out.println("notify 之后");
                }

        });
        notifier.start();
    }
}
